module.exports = function ($scope, $modalInstance, $resource, toaster, obj){

    $scope.obj = obj;

    //保存
	$scope.save = function() {
        if(!$scope.obj.answer_title){
			toaster.warning({title: '', body: '请填写回复标题.'});
			return false;
		}
		if(!$scope.obj.answer_content){
			toaster.warning({title: '', body: '请填写回复内容.'});
			return false;
        }
        
        var para = {
           'info_reply_id' : obj.id
        };
        angular.extend(para, $scope.obj);

		$resource('/api/ac/goc/infoDiffusionService/createAnswer', {}, {}).save(para, function(res){
            if (res.errcode === 0) {
                toaster.success({title: '', body: '保存成功'});
                $modalInstance.close();
            } else {
                toaster.error({title: '', body: res.errmsg});
            }
        });
    }
    
    //取消
    $scope.cannel = function () {
        $modalInstance.dismiss('cancel');
    }
    
};